package com.gaols.utils.custom;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Collections;

/**
 * @author 2019/6/13
 * @create xuewenlong
 */
public class CustomTest {

    public static void main(String[] args) {
        // 总金额 砍价刀数  最小金额
        double total = 40.0;int number = 30;double min = 0.01;
        double money;
        double max;
        int i=1;
        double[] math = new double[number];
        double val = ((double)Math.random());
        while(i<number)
        {
            max = total- min*(number- i);
            int k = (int)((number-i)/2);
            if (number -i <= 2)
            {
                k = number -i;

            }
            max = max/k;

            if (max<min)
            {
                //NSLog(@"max小于min");
                max = min+1;
            }
            money=(int)(min*100+val*(max*100-min*100));
            money=(double)money/100;
            total=new BigDecimal(Double.toString(total)).subtract(new BigDecimal(Double.toString(money))).doubleValue();
            math[i-1] = (double)money;
//	        NSLog(@"第%d人 拿到%f",i,money);
            i++;
            if(i==number)
            {
                math[i-1] = total;
//	            NSLog(@"最后 第%d人 拿到%f",i,money);
            }
        }
        for (double v : math) {
            System.out.println(v);
        }
    }
}
